package com.kasax.ipcbus.corel;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import com.kasax.ipcbus.IpcBusService;
import com.kasax.ipcbus.bean.Request;
import com.kasax.ipcbus.bean.Response;
import com.kasax.ipcbus.corel.marker.InstanceResponseMaker;
import com.kasax.ipcbus.corel.marker.ObjectResponseMaker;
import com.kasax.ipcbus.corel.marker.ResponseMaker;
import com.kasax.ipcbus.utils.LogUtils;

public class CorelService extends Service {
    public CorelService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        LogUtils.i(getClass(), "onBind");
        return new IpcBusService.Stub() {
            @Override
            public Response send(Request request) throws RemoteException {
                LogUtils.i(getClass(), "send");
                ResponseMaker responseMaker = null;
                switch (request.getType()) {
                    case Hermes.TYPE_GET:
                        responseMaker = new InstanceResponseMaker();
                        break;
                    case Hermes.TYPE_NEW:
                        responseMaker = new ObjectResponseMaker();
                        break;
                }
                return responseMaker.makeResponse(request);
            }

        };
    }
}